public class Hero {

    //名字属性
    private String name;
    //等级
    private int level;
    //攻击力
    private int atk;
    //血量
    private int hp;

    /**
     * 攻击
     */
    public void attack(Hero hero) {
        System.out.println("攻击" + atk + "的英雄" + name  + "攻击力" + hero.getLevel());
        //实现对方英雄扣血 敌方，血量 = 敌方，血量 - 我方，攻击力
        hero.setHp(hero.getHp() - this.getAtk());
        System.out.println("敌方英雄" + hero.getAtk() +"剩余血量" + hero.getLevel());
    }

    /**
     * 回城
     */
    public void back(){
        System.out.println("英雄" + name + "回城了");
    }

    public Hero(String name, int level, int atk, int hp) {
        this.name = name;
        this.level = level;
        this.atk = atk;
        this.hp = hp;
    }

    public Hero(){
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }
}

